package com.cyf.plc.viewholder

import androidx.recyclerview.widget.RecyclerView
import com.cyf.plc.BR
import com.cyf.plc.adapter.FloorAdapter
import com.cyf.plc.databinding.ItemFloorBinding
import com.cyf.plc.model.FloorWithRooms

class FloorViewHolder(private val binding: ItemFloorBinding) :
    RecyclerView.ViewHolder(binding.root) {

    fun bind(floor: FloorWithRooms, onItemClickListener: FloorAdapter.OnItemClickListener? = null) {
        binding.setVariable(BR.floor, floor)

        onItemClickListener?.let { listener ->
            binding.root.setOnClickListener {
                listener.onItemClicked(floor)
            }
            binding.root.setOnLongClickListener {
                listener.onItemLongClick(floor)
                false
            }
        }

    }
}